<template>
  <div>
    <FilterTable
      ref="table"
      columnsRef="ygy_additionalProject"
      :columns="columns"
      height="auto"
      :dataSource="dataSource"
      :datakey="'rows'"
      :isSelectColumn="false"
      :onColumnsChange="columns => (this.columns = columns)"
    ></FilterTable>
  </div>
</template>

<script>
import { dictionary } from '@/utils/dictMixin';
import { getAllRepairAddItem } from '@/api/repair/repairManage/repairFeeQuery';

export default {
  name: 'additionalProject',
  components: {},
  mixins: [dictionary],
  props: ['rowData', 'roNo', 'allUser', 'chargePartition', 'dataSource'],
  data() {
    return {
      columns: this.createTableColumns()
    };
  },
  created() {
    let roNo = this.roNo;
    this.fetchParams = Object.assign({}, { roNo: roNo, ownerCode: this.rowData.ownerCode }, { xhrAbort: false });
  },
  mounted() {
    this.columns.find(x => x.dataIndex === 'chargePartitionCode').dictItems = this.chargePartition;
    this.columns.find(x => x.dataIndex === 'chargePartitionCode').filterItems = this.chargePartition;
  },
  methods: {
    createTableColumns() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 50,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        {
          title: '收费区分',
          dataIndex: 'chargePartitionCode',
          minWidth: 100,
          sorter: true,
          showOverflowTooltip: true,
          editable: false,
          defaultEditable: false,
          editType: 'select',
          editItems: []
        },
        {
          title: '附加项目代码',
          dataIndex: 'addItemCode',
          minWidth: 120,
          sorter: true,
          showOverflowTooltip: true
        },
        {
          title: '附加项目名称',
          dataIndex: 'addItemName',
          minWidth: 120,
          sorter: true,
          showOverflowTooltip: true
        },
        {
          title: '附加项目费',
          dataIndex: 'addItemAmount',
          minWidth: 110,
          sorter: true,
          showOverflowTooltip: true
        },
        {
          title: '优惠金额',
          dataIndex: 'discountAmount',
          minWidth: 100,
          sorter: true,
          showOverflowTooltip: true,
          numberFormat: true
        },
        {
          title: '折扣率',
          dataIndex: 'discount',
          minWidth: 90,
          sorter: true,
          showOverflowTooltip: true,
          editable: false,
          defaultEditable: true,
          editType: 'input'
        },
        {
          title: '实收金额',
          dataIndex: 'realReceiveAmount',
          minWidth: 100,
          sorter: true,
          showOverflowTooltip: true,
          numberFormat: true
        }
      ];
    }
  }
};
</script>

<style lang="less"></style>
